<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
</head>
<body>

<div>
    欢迎，<span id="username"></span>
</div>
<div>
    <a href="other.html">other</a>
</div>
</body>
<script>

    window.onload = function () {

        initWelcome();

    }

    function initWelcome() {

      var user=  localStorage.getItem("user");

      user = JSON.parse(user);// json反序列化，把字符串变成json对象

     document.getElementById('username').innerText = user.username;

    }

</script>
</html>